package com.dengqi.mymodule.activity.swipe;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.dengqi.mymodule.BaseActivity;
import com.dengqi.mymodule.R;
import com.wj.refresh.OnRefreshListener;
import com.wj.refresh.PullRefreshLayout;

/**
 * https://github.com/weijia1991/PullRefreshLayout
 */
public class PullwjActivity extends BaseActivity {

    private PullRefreshLayout refreshLayout;
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            refreshLayout.onRefreshComplete();
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_swipe_pullwj);

        refreshLayout = findViewById(R.id.refreshLayout);
        refreshLayout = findViewById(R.id.refreshLayout);
        if (refreshLayout != null) {
            // 刷新状态的回调
            refreshLayout.setOnRefreshListener(new OnRefreshListener() {
                @Override
                public void onPullDownRefresh() {
                    mHandler.sendEmptyMessageDelayed(0, 5000);
                }

                @Override
                public void onPullUpRefresh() {
                    mHandler.sendEmptyMessageDelayed(0, 5000);
                }
            });
        }
    }

}
